#include "attributes.h"
#include <stdlib.h>
#include <string.h>

extern int offset = 0;

char* new_local_name()
{
    //static char* names[] = { "fialho", "soia", "diego", "gracinha" };
    static char* names[] = { "tmp" };
    static char buffer[256];
    static int index = 0;
	//static int offset = 0;
    int random = rand() % (sizeof(names)/sizeof(names[0]));
    char *local;

    //sprintf(buffer,"%s%d",names[random],index++);
	sprintf(buffer,"%03d(Rx)",offset);
	offset+=4;

    local = malloc(strlen(buffer));
    strncpy(local,buffer,strlen(buffer));

    return local;
}

Attributes* create_attr()
{
    Attributes* attr = malloc(sizeof(Attributes));
    attr->local = NULL;
    attr->code = NULL;
    return attr;
}

char* create_label()
{
    static char buffer[256];
    static int index = 0;
    char *local;

    sprintf(buffer,"L%d",index++);

    local = malloc(strlen(buffer));
    strncpy(local,buffer,strlen(buffer));

    return local;
}
